package com.ruoyi.web.controller.enterprise;

import java.io.IOException;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.vo.GwSealInfoVO;
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.GwSealInfo;
import com.ruoyi.system.service.IGwSealInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 企业印章管理Controller
 * 
 * @author ruoyi
 * @date 2025-05-26
 */
@RestController
@RequestMapping("/system/sealInfo")
public class GwSealInfoController extends BaseController
{
    @Autowired
    private IGwSealInfoService gwSealInfoService;

    /**
     * 查询企业印章管理列表
     */
//    @PreAuthorize("@ss.hasPermi('system:sealInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(GwSealInfo gwSealInfo)
    {
        startPage();
        List<GwSealInfoVO> list = gwSealInfoService.selectList(gwSealInfo);
        return getDataTable(list);
    }

    /**
     * 导出企业印章管理列表
     */
//    @PreAuthorize("@ss.hasPermi('system:sealInfo:export')")
    @Log(title = "企业印章管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GwSealInfo gwSealInfo)
    {
        List<GwSealInfo> list = gwSealInfoService.selectGwSealInfoList(gwSealInfo);
        ExcelUtil<GwSealInfo> util = new ExcelUtil<GwSealInfo>(GwSealInfo.class);
        util.exportExcel(response, list, "企业印章管理数据");
    }

    /**
     * 获取企业印章管理详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:sealInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(gwSealInfoService.selectGwSealInfoById(id));
    }

    /**
     * 新增企业印章管理
     */
//    @PreAuthorize("@ss.hasPermi('system:sealInfo:add')")
    @Log(title = "企业印章管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GwSealInfo gwSealInfo) throws TencentCloudSDKException, IOException {
        return  gwSealInfoService.insertGwSealInfo(gwSealInfo);
    }

    /**
     * 修改企业印章管理
     */
//    @PreAuthorize("@ss.hasPermi('system:sealInfo:edit')")
    @Log(title = "企业印章管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GwSealInfo gwSealInfo)
    {
        return toAjax(gwSealInfoService.updateGwSealInfo(gwSealInfo));
    }

    /**
     * 删除企业印章管理
     */
//    @PreAuthorize("@ss.hasPermi('system:sealInfo:remove')")
    @Log(title = "企业印章管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) throws TencentCloudSDKException {
        return toAjax(gwSealInfoService.deleteGwSealInfoByIds(ids));
    }

    /**
     * 查询电子签印章
     */
    @PostMapping(value = "/getSealUrl")
    public AjaxResult getSealUrl(@RequestBody GwSealInfo gwSealInfo) throws TencentCloudSDKException {
        return gwSealInfoService.getSealUrl(gwSealInfo);
    }
}
